package com.zyw.controller.repertory;


import com.zyw.entity.RepertoryFinish;
import com.zyw.entity.RepertoryMaterial;
import com.zyw.from.repertoryFrom;
import com.zyw.service.repertory.RepertoryFinishService;
import com.zyw.util.ResultVOUtil;
import com.zyw.util.UnitConversionUtil;
import com.zyw.vo.LayUITableVO;
import com.zyw.vo.ResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@Slf4j
@RequestMapping("/repertory/finish")
public class RepertoryFinishController {

    @Autowired
    public RepertoryFinishService repertoryFinishService;

    //菜品类别展示
    @GetMapping("/index")
    public String index(Model model){



        return "repertory/finish/index";

    }
    //获取菜品类别信息
    @GetMapping("/list")
    @ResponseBody
    public LayUITableVO<List<RepertoryFinish>> list (@RequestParam(defaultValue = "1") Integer page,
                                                       @RequestParam(defaultValue = "10") Integer limit,
                                                       repertoryFrom from){

        Map<String ,Object> map = new HashMap<>();
        map.put("page",page);
        map.put("limit",limit);
        map.put("from",from);
        LayUITableVO< List<RepertoryFinish>> vo = repertoryFinishService.findPage(map);


        return vo;
    }


    //执行修改
    @PostMapping("/edit")
    @ResponseBody
    public ResultVO edit(RepertoryFinish repertoryFinish){

        repertoryFinish.setComeDate(UnitConversionUtil.nowDate());
        //TODO 登录用户名称
        repertoryFinish.setComePeo("xx");
        repertoryFinishService.update(repertoryFinish);

        return ResultVOUtil.ok();
    }

}
